{# SPDX-FileCopyrightText: © 2014-2015 Siemens AG

   SPDX-License-Identifier: FSFAP
#}
{% extends "include/base.html.twig" %}

{% block content %}
<link rel="stylesheet" type="text/css" href="css/select2.min.css"/>
<link rel="stylesheet" type="text/css" href="css/select2.custom.css"/>

  <form name="formy" method="post">
    {{ "Select an uploaded file for additional analysis."|trans }}
    <ol>
      <br/>
      <li>{{"Select the folder containing the upload you wish to analyze"|trans}}:<br/>
        <select name="folder" onLoad="Uploads_Get('{{ baseUri }}?mod=upload_options&folder={{ folderId }}');"
                onChange="Uploads_Get('{{ baseUri }}?mod=upload_options&folder=' + this.value);" class="ui-render-select2">
          {{ folderListOptions }}
        </select>
      </li>
      <br/>
      <li>
        {{"Select the upload to analyze"|trans}}:<br/>
        <div id="uploaddiv">
          <select size="10" name="upload" id="uploadToAnalyze" onChange="Agents_Get('{{ baseUri }}?mod=upload_agent_options&upload=' + this.value);">
            {% for foliup in folderListUploads %}
              <option value="{{ foliup.upload_pk }}" {% if uploadId==foliup.upload_pk %}selected="selected"{% endif %}>
               {{ foliup.name|e }} {% if foliup.upload_desc is not empty %}({{ foliup.upload_desc|e }}){% endif %}
              </option>
            {% endfor %}
          </select>
        </div>
      </li>
      <br/>
      <li>
         <input type="checkbox" name="scm" value="1"/> {{ 'Ignore files with particular Mimetype'| trans }}<img src="images/info_16.png" title="{{'Configure mimetypes from Admin-Customize-Skip MimeTypes from scanning'|trans}}" alt="" class="info-bullet"/><br/>
     </li>
     <br/>
      <li> {{ "Select additional analysis."|trans }}<br/>
        <div id="agentsdiv">
          <div class="no-agents-message">
            {{ 'No additional analysis available'|trans }}
          </div>
        </div>
        {{ out }}
      </li> 
    </ol>
    <input type="submit" value="{{ 'Analyze'|trans}}"/>
  </form>
{% endblock %}

{% block foot %}
  {{ parent() }}
  <script type="text/javascript">
    const select2f = {
      select2Search: function() {
        $('#uploadToAnalyze').select2({
        "placeholder": "Select upload to analyze"
        });
      }
    }
    $(document).ready(function () {
      $('img').tooltip();
      select2f.select2Search();
    });
  </script>
  {% if uploadId %}
    <script language="javascript">
      Agents_Get("{{ baseUri }}?mod=upload_agent_options&upload={{ uploadId }}");
    </script>
  {% endif %}
  {{ uploadScript }}
  <script language="javascript">
    function Uploads_Reply()
    {
      if ((Uploads.readyState==4) && (Uploads.status==200))
      {
        document.getElementById('uploaddiv').innerHTML = '<select size="10" name="upload" id="uploadToAnalyze" onChange="Agents_Get(\'{{ baseUri }}?mod=upload_agent_options&upload=\' + this.value)">' + Uploads.responseText + '</select><p/>';
        document.getElementById('agentsdiv').innerHTML = '<div class="no-agents-message">{{ "No additional analysis available"|trans }}</div>';
      }
      select2f.select2Search();
    }
  </script>

  {{ agentScript }}
  <script language="javascript">
    function Agents_Reply()
    {
      if ((Agents.readyState==4) && (Agents.status==200))
      {
        if (Agents.responseText.trim() === '' || Agents.responseText.indexOf('<option') === -1) {
          document.getElementById('agentsdiv').innerHTML = '<div class="no-agents-message">{{ "No additional analysis available"|trans }}</div>';
        } else {
          document.getElementById('agentsdiv').innerHTML = Agents.responseText;
        }
      }
    }
  </script>
  {{ paramIncludes }}
  {{ outFoot }}
{% endblock %}
